package demo.practice.leetcode_base;

import java.util.HashMap;
import java.util.Map;

public class P28 {

    public static void main(String[] args) {
        P28 p28= new P28();
        p28.strStr("hello","ll");
    }



    public int strStr(String haystack, String needle) {
//        return haystack.indexOf(needle);
        if(needle.length()==0)
            return 0;
        for(int i =0;i<haystack.length()-needle.length();i++){
            int g=i;
            for(int j=0;j<needle.length();j++,g++){
                if(needle.charAt(j)!=haystack.charAt(g))
                    break;

                if(j==needle.length()-1)
                    return i;
            }
        }
        return -1;
    }
}
